/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package drivemachine;

import drivemachine.data2.CompareEntry;
import drivemachine.data2.FolderEntry;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

/**
 *
 * @author positron
 */
public class CompTreeModel implements TreeModel  {
	Comparator cc;
	TreeModelListener l;

	public void update(){
		//l.treeNodesInserted(new TreeModelEvent(s.root, new Object[]{s.root}));
		if (cc.root==null) l.treeStructureChanged(new TreeModelEvent(null, (Object[])null)); else
		l.treeStructureChanged(new TreeModelEvent(cc.root, new Object[]{cc.root}) );
	}

	public CompTreeModel(Comparator s) {
		//this.cc = s;
	}

	@Override
	public Object getRoot() {
		return cc.root;
	}

	@Override
	public Object getChild(Object parent, int index) {
		return null;//((CompareEntry)parent).getChildren().get(index);
	}

	@Override
	public int getChildCount(Object parent) {
		return 0;//((CompareEntry)parent).getChildren().size();
	}

	@Override
	public boolean isLeaf(Object parent) {
		return true;//((CompareEntry)parent).getChildren().isEmpty();
	}

	@Override
	public void valueForPathChanged(TreePath path, Object newValue) {
        System.out.println("*** valueForPathChanged : " + path + " --> " + newValue);
	}

	@Override
	public int getIndexOfChild(Object parent, Object child) {
		return 0;//((CompareEntry)parent).children.indexOf( ((FolderEntry)child) );
	}

	@Override
	public void addTreeModelListener(TreeModelListener l) {
		this.l=l;
	}

	@Override
	public void removeTreeModelListener(TreeModelListener l) {
		this.l=null;
	}

}
